home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 112 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.4 KB

  1. Path: fido.asd.sgi.com!austern
  2. From: Michael Cook <mcook@cognex.com>
  3. Newsgroups: comp.std.c++
  4. Subject: operator T* ambiguities
  5. Date: 23 Jan 1996 10:21:32 PST
  6. Organization: Cognex Corporation, Natick, Massachusetts
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <r47myjasnx.fsf@erawan.cognex.com>
  9. NNTP-Posting-Host: isolde.mti.sgi.com
  10. X-Original-Date: 23 Jan 1996 09:32:02 -0500
  11. X-Newsreader: September Gnus v0.26/Emacs 19.29
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBVAwUBMQUnREy4NqrwXLNJAQH5ZwIAy1IN19JyYK2cOfBMsm4xbygLpTCPHDpa
  14.     XkO/UTy9bKFUGszrwzzh3GDTBQ9eWm7xJ4XwETLcIZnosrf/obNU0w==
  15.     =Ie1u
  16. Originator: austern@isolde.mti.sgi.com
  17.  
  18. Does the standards committee consider this code ambiguous:
  19.  
  20.   struct X;
  21.   struct Y
  22.   {
  23.       operator X*();
  24.       operator const X*() const;
  25.   };
  26.   void* f(Y y)
  27.   {
  28.       return y; //10
  29.   }
  30.  
  31. A couple compilers (different vendors) say it /is/ ambiguous, but I can't see
  32. why.  Shouldn't the compiler decide that `y.operator X*()' is a better choice
  33. because `y' is not `const'--just as for other overload resolution?
  34.  
  35. (In particular, gcc says
  36.   x.C:10: ambiguous conversion from `Y' to `void *'
  37.   x.C:10:   candidate conversion functions include `const X *' and `X *'
  38. .)
  39.  
  40. Michael.
  41. ---
  42. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  43.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  44.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  45.